package com.googlecode.imanager.swing.form;

import javax.swing.JTextField;

import com.googlecode.imanager.client.bridge.form.ITextBox;
import com.googlecode.imanager.client.form.TextBox;
import com.googlecode.imanager.core.base.BridgeApplication;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class SwingTextBox extends SwingInputText implements ITextBox {

    public SwingTextBox(BridgeApplication bridge, TextBox source) {
        super(bridge, source);
    }

    @Override
    protected JTextField createTarget() {
        return new JTextField();
    }

    @Override
    public JTextField getTarget(){
        return (JTextField) target;
    }
    
    @Override
    public TextBox getSource() {
        return (TextBox) source;
    }

    @Override
    public void setMaxLength(Integer maxLength) {
        getTarget().setColumns(maxLength == null ? 0 : maxLength);
    }

}
